#!/bin/bash
<<comment
使用echo打印一个菜单,联系echo的用法
echo可用指定字体颜色,背景色,字体样式等信息
comment

font_bold="\033[1m"
font_black="\033[30m"
font_red="\033[31m"
font_green="\033[32m"
font_brown="\033[33m"
font_bule="\033[34m"
font_purple="\033[35m"
font_blue_green="\033[36m"
font_hign_gray="\033[37m"
font_bg_green="\033[42m"

font_end="\033[0m"

# 第一个参数字体颜色
# 第一个参数消息内容
echoMenuItem() {
    echo -e "#$1$2${font_end}"
}


# 使用%10s指定字符串宽度的时候,中文个数不相等的时候,显示长度会有问题,不知道啥情况
printMenuItem(){
   printf "#$1%-40s${font_end}\n" "$2"
}

clear
echo -e "${font_bold}-------------------------------------------${font_end}"
#使用[2;10H移动光标位置
#echo -e "\033[2;10H#\t\t这是一个菜单\t\t#"
echo -e "\033[5:5H#\t\t这是一个菜单\t\t#"
echoMenuItem ${font_red} "1.查看CPU信息"
echoMenuItem ${font_green} "2.查看内存信息"
echoMenuItem ${font_bule} "3.查看磁盘信息"
echoMenuItem ${font_brown} "4.查看网络信息"
echoMenuItem ${font_purple} "5.查看账户信息"
echo -e  "${font_bold}-------------------------------------------${font_end}"
echo
echo
echo -e "${font_bold}-------------------------------------------${font_end}"
printf "#\t\t%s\t\t#\n" "这是一个print打印的菜单" 
printMenuItem "${font_red}" "1.查看CPU信息"
printMenuItem "${font_green}" "2.查看内存信息"
printMenuItem "${font_bule}" "3.查看磁盘信息"
printMenuItem "${font_brown}" "4.查看网络信息"
printMenuItem "${font_purple}" "5.查看账户信息"
echo -e "${font_bold}-------------------------------------------${font_end}"
